<%@ page contentType="text/html; charset=utf-8" language="java"
	errorPage=""%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/web/common/taglibs.jsp"%>
<script type='text/javascript' src='web/js/calender.js'></script>
<script>
window.onload=function(){
    var tdh1 = window.screen.height / 1000;
    var tds = document.getElementsByTagName('TD');
    for(var i=0;i<tds.length;i++){
        if(tds[i].className == 'td-h-10'){
            tds[i].height=tdh1 * 10+'px';
        } else if(tds[i].className == 'td-h-8') {
            tds[i].height=tdh1 * 8+'px';
        } else if(tds[i].className == 'td-h-4') {
            tds[i].height=tdh1 * 4+'px';
        }
    }
    document.getElementById('dv').style.height=tdh1 * 310 + 'px';
}

</script>
<s:form action="_recordCreate" method="post">
<s:hidden name="recordForm.inputRecordIdHid"></s:hidden>
<s:hidden name="recordForm.selectedType1Hid"></s:hidden>
<s:hidden name="recordForm.selectedType2Hid"></s:hidden>
<s:hidden name="recordForm.selectedPrivacyHid"></s:hidden>
<s:hidden name="recordForm.recordDateFromHid"></s:hidden>
<s:hidden name="recordForm.recordDateToHid"></s:hidden>
<s:hidden name="recordForm.inputSubjectHid"></s:hidden>
<s:hidden name="recordForm.searchFlgHid"></s:hidden>
	<table cellpadding="0" cellspacing="0" width="100%">
		<tr>
			<td class="td-h-10"></td>
		</tr>
		<tr>
			<td width="10px"></td>
			<td><font class="title"><s:property
				value='%{getText("record_create_title")}' /></font></td>
		</tr>
		<tr>
			<td class="td-h-10"></td>
			<td><s:fielderror/></td>
		</tr>
		<tr>
			<td></td>
			<td>
			<table border="0" class="tb-content-bg" cellpadding="0"
				cellspacing="0">
				<tr>
					<td class="td-h-8" width="8px;"></td>
				</tr>
				<tr>
					<td></td>
					<td valign="middle" class="tb-label"><s:property
						value='%{getText("record_create_type1")}' /></td>
					<td width="180px"><s:select
						name="recordCreateForm.selectedType1" cssClass="select-160"
						list="recordCreateForm.type1List" headerKey="0" headerValue=""
						listKey="value" listValue="label"></s:select></td>
					<td width="4%"></td>
					<td valign="middle" class="tb-label"><s:property
						value='%{getText("record_create_type2")}' /></td>
					<td width="180px"><s:select
						name="recordCreateForm.selectedType2" cssClass="select-160"
						list="recordCreateForm.type2List" headerKey="0" headerValue=""
						listKey="value" listValue="label"></s:select></td>
				</tr>
				<tr>
					<td class="td-h-4"></td>
				</tr>
				<tr>
					<td></td>
					<td valign="middle" class="tb-label"><s:property
						value='%{getText("record_create_status")}' /></td>
					<td width="180px"><s:select
						name="recordCreateForm.selectedPrivacy" cssClass="select-160"
						list="recordCreateForm.privacyList" headerKey="0" headerValue=""
						listKey="value" listValue="label"></s:select></td>
					<td></td>
				</tr>
				<tr>
					<td class="td-h-4"></td>
				</tr>
				<tr>
					<td></td>
					<td valign="middle" class="tb-label"><s:property
						value='%{getText("record_create_subject")}' /></td>
					<td colspan="4"><s:textfield cssClass="txt-350"
						maxlength="200" name="recordCreateForm.subject" /></td>
				</tr>
				<tr>
					<td class="td-h-4"></td>
				</tr>
				<tr>
					<td></td>
					<td valign="middle" class="tb-label"><s:property
						value='%{getText("record_create_comment")}' /></td>
					<td colspan="4"><s:textarea cssClass="txtarea-350" rows="80"
						cols="14" name="recordCreateForm.comment" /></td>
				</tr>
				<tr>
					<td class="td-h-10"></td>
				</tr>
				<tr>
					<td></td>
					<td valign="middle" class="tb-label"><s:property
						value='%{getText("record_create_count")}' /></td>
					<td colspan="4"><s:textfield cssClass="txt-160" maxlength="20"
						name="recordCreateForm.totalCount" /></td>
				</tr>
				<tr>
					<td class="td-h-10"></td>
				</tr>
				<tr>
					<td></td>
					<td><font class="title2"><s:property
						value='%{getText("record_create_list")}' /></font></td>
					<td></td>
					<td colspan="2">
					<td><s:submit cssClass="btn-50"
						value='%{getText("btn_submit")}' onclick="return onSubmit();"
						method="submitRecord" /> <s:submit cssClass="btn-50"
						value='%{getText("btn_back")}' onclick="onBack();" method="goBack" />
					</td>
				</tr>
				<tr>
					<td class="td-h-8"></td>
				</tr>
				<tr>
					<td></td>
					<td colspan="5">
					<div class="div-scroll" style="width: 98%;" id="dv">
					<table border="0" cellpadding="0" cellspacing="0" width="100%"
						style="position: relative;">
						<tr>
							<td>
							<div style="width: 100%;" style="position: relative;">
							<table id="list-tb" cellpadding="0" cellspacing="0"
								class="tb-list" width="100%">
								<tr>
									<td class="td-list-title-left" width="60px"></td>
									<td class="td-list-title-right" width="40px"><s:property
										value='%{getText("record_create_sub_recordId")}' /></td>
									<td class="td-list-title-right" width="25%"><s:property
										value='%{getText("record_create_sub_subject")}' /></td>
									<td class="td-list-title-right" width="12%"><s:property
										value='%{getText("record_create_sub_count")}' /></td>
									<td class="td-list-title-right"><s:property
										value='%{getText("record_create_detail")}' /></td>
									<td class="td-list-title-right" width="90px"><s:property
										value='%{getText("record_create_cardOrCash")}' /></td>
								</tr>
							</table>
							</div>
							</td>
							<td id="addBtn-td" width="60px" valign="bottom"><input
								type="button" class="btn-50" onclick="addItem();return false;"
								value="<s:property value='%{getText("btn_add")}' />" /></td>
						</tr>
					</table>
					</div>
					</td>
				</tr>
				<tr>
					<td class="td-h-8"></td>
				</tr>
			</table>
			</td>
		</tr>
	</table>
	<div id="hid" style="display: none;"><s:select name='yyy.xxx'
		style="width:100%" list='recordCreateForm.cardOrCashList'
		headerKey='0' headerValue='' listKey='value' listValue='label'></s:select>
	</div>
</s:form>
<script>
var itemIndex = 1;
function addItem() {
    var tb = document.getElementById('list-tb');
    var newRow; 
    newRow = tb.insertRow(tb.rows.length);

    var newCell1;
    newCell1 = newRow.insertCell();
    newCell1.innerHTML = "<input type='button' onclick='removeItem(this);return false;' value='" + "<s:property value='%{getText("btn_remove")}' />" + "' class='btn-50' />";
    newCell1.className='td-list-content-left';

    var newCell2;
    newCell2 = newRow.insertCell();
    newCell2.name="subIds";
    newCell2.innerText = itemIndex++;
    newCell2.className='td-list-content-right';

    var newCell3;
    newCell3 = newRow.insertCell();
    newCell3.innerHTML = '<s:textfield style="width:98%" name="recordCreateForm.subSubject" maxlength="200"/>';
    newCell3.className='td-list-content-right';

    var newCell4;
    newCell4 = newRow.insertCell();
    newCell4.innerHTML = '<s:textfield style="width:95%" name="recordCreateForm.subCount" maxlength="20"/>';
    newCell4.className='td-list-content-right';

    var newCell5;
    newCell5 = newRow.insertCell();

    var html;
    html = '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>';
    html += '<s:textfield style="width:97%" name="recordCreateForm.recordDetail" maxlength="1024"/></td><td width="52px">';
    html += "<input type='button' value='" + "<s:property value='%{getText("btn_edit")}' />" + "' class='btn-50' />";

    html += '</td></tr></table>';
    newCell5.innerHTML = html;
    newCell5.className='td-list-content-right';

    var select1;
    select1 = document.getElementById('hid').innerHTML;

    var newCell6;
    newCell6 = newRow.insertCell();
    newCell6.innerHTML = select1.replace("xxx","cardOrCash").replace("yyy","recordCreateForm").replace("xxx","cardOrCash").replace("yyy","recordCreateForm");
    newCell6.className='td-list-content-right';

    resetAddBtn();
}
function removeItem(nod) {
	var tb = document.getElementById('list-tb');
	var index = nod.parentNode.parentNode.rowIndex;
	tb.deleteRow(nod.parentNode.parentNode.rowIndex);
	for(var i = index; i < tb.rows.length; i++){
	    tb.rows(i).cells(1).innerText = i;
	}
	resetAddBtn();
}
function resetAddBtn(){
	document.getElementById('addBtn-td').innerHTML = '<input type="button" class="btn-50" onclick="addItem();return false;" value="<s:property value='%{getText("btn_add")}' />" />';
}
function onSubmit() {
	if(!confirm("<s:property value='%{getText("submit_confirm_msg")}' />")) {
	    return false;
	}
    if(!checkSelectRequired('recordCreateForm.selectedType1',"<s:property value='%{getText("type1_empty_error")}' />")) {
        return false;
    }
    if(!checkSelectRequired('recordCreateForm.selectedType2',"<s:property value='%{getText("type2_empty_error")}' />")) {
        return false;
    }
    if(!checkSelectRequired('recordCreateForm.selectedPrivacy',"<s:property value='%{getText("status_empty_error")}' />")) {
        return false;
    }
    if(!checkTextRequired('recordCreateForm.subject',"<s:property value='%{getText("subject_empty_error")}' />")) {
        return false;
    }
    if(!checkTextRequired('recordCreateForm.totalCount',"<s:property value='%{getText("sum_empty_error")}' />")) {
        return false;
    }
    if(!checkTextRequired('recordCreateForm.subSubject',"<s:property value='%{getText("sub_subject_empty_error")}' />")) {
        return false;
    }
    if(!checkTextRequired('recordCreateForm.subCount',"<s:property value='%{getText("sub_count_empty_error")}' />")) {
        return false;
    }
    if(!checkSelectRequired('recordCreateForm.cardOrCash',"<s:property value='%{getText("coc_empty_error")}' />")) {
        return false;
    }
    var names = new Array();
    names[0]='recordCreateForm.subCount';
    names[1]='recordCreateForm.totalCount';
    if(!checkNaN(names,"<s:property value='%{getText("money_format_error")}' />")){
        return false;
    }
    return true;
}
function onBack() {
	
}
</script>
</html>